package cn.sytton.taffe.log.entity;

import cn.sytton.taffe.framework.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

/**
 * 用户操作日志Entity
 *
 * @author skyrock
 */
@Schema(description = "用户操作日志")
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_user_log")
public class UserLogEntity extends BaseEntity {

    @Schema(description = "日志ID")
    @TableId(type = IdType.ASSIGN_ID)
    private String logId;       //日志ID

    @Schema(description = "用户ID")
    @JsonIgnore
    private String userId;    //用户ID

    @Schema(description = "登录账号")
    private String loginName; //登录账号

    @Schema(description = "用户编号")
    private String userCode;  //用户编号

    @Schema(description = "用户姓名")
    private String userName;  //用户姓名

    @Schema(description = "用户ID")
    private String menuUrl;   //菜单地址

    @Schema(description = "菜单名称")
    private String menuName;  //菜单名称

    @Schema(description = "操作名")
    private String action;    //操作名

    @Schema(description = "访问来源: pc, android, ios, weixin")
    private String accessSource; //访问来源: pc, android, ios, weixin

    @Schema(description = "日志类型: menu, action")
    private String logType;   //日志类型: menu, action

    @Schema(description = "日志时间")
    @JsonFormat
    private Timestamp logTime; //日志时间

    @Schema(description = "访问IP")
    private String ip;         //访问IP

    @Schema(description = "物理地址")
    private String location;   //物理地址

    @Schema(description = "操作系统")
    private String os;         //操作系统

    @Schema(description = "浏览器")
    private String browser;     //浏览器

    //-----以下是关联属性-----

    @Schema(description = "查询开始时间")
    @JsonFormat
    @TableField(exist = false)
    private Timestamp queryBeginTime;  //查询开始时间

    @Schema(description = "查询结束时间")
    @JsonFormat
    @TableField(exist = false)
    private Timestamp queryEndTime;    //查询结束时间
}
